<template>
  <div class="goods-message">
    <div class="goods-name">{{goods.title}}</div>
    <div class="goods-discount-box">
      <span class="goods-discount" :style="{backgroundColor: goods.discountBgColor}">{{goods.discountDesc}}</span>
    </div>
    <div class="goods-price">
      <span>{{goods.price}}</span>
      <span>{{goods.oldPrice}}</span>
    </div>
    <div class="goods-star">
      <div v-for="(item, index) in goods.columns"
           :key="index"
           class="goods-star-item">
        {{item}}
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "GoodsName",
  props: {
    goods: {
      type: Object,
      default() {
        return {}
      }
    }
  }
}
</script>

<style scoped>
  .goods-name {
    font-size: 18px;
    color: #000000;
    word-break: break-all;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .goods-price {
    box-sizing: content-box;
    height: 30px;
    padding: 10px 0;
  }
  .goods-price span {
    margin-right: 10px;
  }
  .goods-price span:nth-child(1) {
    font-size: 28px;
    color: var(--color-high-text);
  }
  .goods-price span:nth-child(2) {
    color: var(--color-text);
    text-decoration: line-through;
  }
  .goods-discount-box {
    box-sizing: content-box;
    margin-top: 20px;
    margin-bottom: 6px;
  }
  .goods-discount {
    color: #ffffff;
    border-radius: 10px;
    padding: 4px;
  }
  .goods-star {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
  }
  .goods-star-item {
    flex: 1;
    color: #a3a3a5;
    font-size: 16px;
  }
  .goods-star-item:nth-child(2) {
    text-align: center;
  }
  .goods-star-item:nth-child(3) {
    text-align: right;
  }
</style>